﻿#pragma once
#include <Qt3DExtras/Qt3DWindow>
#include <Qt3DExtras/QOrbitCameraController>
#include <Qt3DRender/QCamera>
#include <Qt3DCore/QEntity>
#include <Qt3DCore/QTransform>
#include <Qt3DExtras/QCylinderMesh>
#include <Qt3DExtras/QPhongMaterial>

class RobotArm : public Qt3DCore::QEntity {
public:
	RobotArm(Qt3DCore::QEntity* parent = nullptr);
	void moveToPosition(const QVector3D& target);

private:
	struct Joint {
		Qt3DCore::QEntity* entity;
		Qt3DCore::QTransform* transform;
		float length;
		float angle = 0; // 当前关节角度
	};

	QVector<Joint> joints;
	void solveIK(const QVector3D& target);
};
